package com.advice;

import org.springframework.aop.AfterReturningAdvice;
import org.springframework.aop.ThrowsAdvice;

import java.lang.reflect.Method;

//最终增强 --后置增强+异常增强
public class AfterService implements AfterReturningAdvice, ThrowsAdvice {
    @Override
    public void afterReturning(Object returnValue, Method method, Object[] args, Object target) throws Throwable {
        System.out.println("----------AfterService的后置增强start-------------");
        System.out.println(target+"的"+method.getName()+"方法返回值是+"+returnValue);
        System.out.println("----------AfterService的后置增强end-------------");
    }
    public void afterThrowing(Method method, Object[] args, Object target, Exception e) throws Throwable{
        System.out.println("=======AfterService的异常抛出增强start=========");
        System.out.println(target + "的" + method.getName() + "方法抛出的异常是" + e.getMessage());
        System.out.println("=======AfterService的异常抛出增强end=========");
    }
}
